/**
 * 通过 mock api 的形式模拟实际项目中的接口
 * 可通过 mock/index.js 模拟数据，类似 express 的接口
 * 参考： https://alibaba.github.io/ice/docs/pro/mock
 */

import {
  request,
  fetchDataWithGet,
  fetchDataWithPost,
  fetchDataWithDelete,
} from './AxiosData';

import {
  GetTokenDataURL,
  GetLoginDataURL,
  GetRoleDataURL,
  GetMenuDataURL,
  GetMyProjectDataURL,
  GetLoanItemFindURL,
  GetLogListURL,
  GetPaymentPlanURL,
  GetReturnVisitURL,
  GetApprovalHistoryURL,
  GetSaveProjectURL,
  GetDelProjectURL,
  GetEditProjectURL,
  GetModelListURL,
  GetProcessListURL,
  GetTaskListURL,
  GetWorkFlowStartURL,
  GetDeployURL,
  GetGetTaskURL,
  GetTurnDownCancelURL,
  GetWorkFlowCompleteURL,
  GetTurnDownSponsorURL,
  GetTurnDownPreviousURL,
  GetInstanceListURL,
  GetCirculationURL,
  GetFreeCirculationURL,
} from './UrlConfig';


export function requestToken(username, password) {
  return request(GetTokenDataURL, {
    method: 'post',
    body: {
      username,
      password,
    },
  });
  // return fetchDataWithPost(GetTokenDataURL,{
  //   username: username,
  //   password: password,
  // });
}

export function login(token) {
  return request(GetLoginDataURL, {
    method: 'post',
    body: {
      oken: token,
    },
  });
  // return fetchDataWithPost(GetLoginDataURL,{
  //   token: token,
  // });
}

export function getSystemRole() {
  return request(GetRoleDataURL, {
    method: 'get',
    body: {},
  });
  // return fetchDataWithGet(GetRoleDataURL);
}

export function getMenus() {
  return request(GetMenuDataURL, {
    method: 'get',
    body: {},
  });
  // return fetchDataWithGet(GetMenuDataURL);
}

export function getLoanList(page) {
  return request(GetMyProjectDataURL, {
    method: 'get',
    body: {
      current: page,
    },
  });
  // return fetchDataWithGet(GetMyProjectDataURL,{
  //   current: page
  // });
}

export function getLoanItem(itemApplyId) {
  return request(GetLoanItemFindURL, {
    method: 'get',
    body: {
      itemApplyId,
    },
  });
  // return fetchDataWithGet(GetLoanItemFindURL,{
  //   itemApplyId: itemApplyId
  // });
}

export function getLogList() {
  return request(GetLogListURL, {
    method: 'get',
    body: {},
  });
  // return fetchDataWithGet(GetLogListURL);
}

export function getPaymentPlay() {
  return request(GetPaymentPlanURL, {
    method: 'get',
    body: {},
  });
  // return fetchDataWithGet(GetPaymentPlanURL);
}

export function getReturnVisit() {
  return request(GetReturnVisitURL, {
    method: 'get',
    body: {},
  });
  // return fetchDataWithGet(GetReturnVisitURL);
}

export function getApprovalHistory(data) {
  return request(GetApprovalHistoryURL, {
    method: 'get',
    body: data,
  });
  // return fetchDataWithGet(GetApprovalHistoryURL,data);
}

export function addProject(data) {
  return request(GetSaveProjectURL, {
    method: 'post',
    body: data,
  });
  // return fetchDataWithPost(GetSaveProjectURL,data);
}

export function delProject(id) {
  return request(GetDelProjectURL, {
    method: 'delete',
    body: {
      itemApplyId: id,
    },
  });
  // return fetchDataWithDelete(GetDelProjectURL,{
  //   itemApplyId: id
  // });
}

export function editProject(data) {
  return request(GetEditProjectURL, {
    method: 'post',
    body: data,
  });
  // return fetchDataWithPost(GetEditProjectURL,data);
}

export function getTemplateList(page) {
  return request(GetModelListURL, {
    method: 'get',
    body: {
      current: page,
    },
  });
  // return fetchDataWithGet(GetModelListURL,{
  //   current: page
  // });
}

export function getDefinitionList(page) {
  return request(GetProcessListURL, {
    method: 'get',
    body: {
      current: page,
    },
  });
  // return fetchDataWithGet(GetProcessListURL,{
  //   current: page
  // });
}

export function getTaskList(data) {
  return request(GetTaskListURL, {
    method: 'get',
    body: data,
  });
  // return fetchDataWithGet(GetTaskListURL,data);
}

export function workFlowStart(data) {
  return request(GetWorkFlowStartURL, {
    method: 'post',
    body: data,
  });
  // return fetchDataWithPost(GetWorkFlowStartURL,data);
}

export function getDeployList(modelId) {
  return request(GetDeployURL, {
    method: 'get',
    body: {
      modelId,
    },
  });
  // return fetchDataWithGet(GetDeployURL,{
  //   modelId: modelId
  // });
}

export function getTaskInfo(data) {
  return request(GetGetTaskURL, {
    method: 'get',
    body: data,
  });
  // return fetchDataWithGet(GetGetTaskURL,data);
}

export function turnDownCancel(data) {
  return request(GetTurnDownCancelURL, {
    method: 'post',
    body: data,
  });
  // return fetchDataWithPost(GetTurnDownCancelURL,data);
}

export function workFlowComplete(data) {
  return request(GetWorkFlowCompleteURL, {
    method: 'post',
    body: data,
  });
  // return fetchDataWithPost(GetWorkFlowCompleteURL,data);
}

export function turnDownSponsor(data) {
  return request(GetTurnDownSponsorURL, {
    method: 'post',
    body: data,
  });
  // return fetchDataWithPost(GetTurnDownSponsorURL,data);
}

export function turnDownPrevious(data) {
  return request(GetTurnDownPreviousURL, {
    method: 'post',
    body: data,
  });
  // return fetchDataWithPost(GetTurnDownPreviousURL,data);
}

export function getInstanceList(data) {
  return request(GetInstanceListURL, {
    method: 'get',
    body: data,
  });
  // return fetchDataWithGet(GetInstanceListURL,data);
}

export function getCirculation(data) {
  return request(GetCirculationURL, {
    method: 'get',
    body: data,
  });
  // return fetchDataWithGet(GetCirculationURL,data);
}

export function getFreeCirculation(data) {
  return request(GetFreeCirculationURL, {
    method: 'get',
    body: data,
  });
  // return fetchDataWithGet(GetFreeCirculationURL,data);
}
